#include "stdafx.h"
#include "_YMarker.h"

void _YMarker::draw(double Min, double Max, _u32 BorderSize, _u32 YAxisWidth, _u32 XAxisHeight, _u32 TitleHeight)
{
    glColor3i(GET_GLINT_R(m_Color), GET_GLINT_G(m_Color), GET_GLINT_B(m_Color));
    glLoadIdentity();
    _u32 Width  = m_Layout.m_ControlRect.Width() - BorderSize * 2 - YAxisWidth;
    _u32 Height = m_Layout.m_ControlRect.Height() - BorderSize * 2 - XAxisHeight - TitleHeight;
    glViewport(BorderSize + YAxisWidth,
               BorderSize + XAxisHeight,
               Width,
               Height);
    gluOrtho2D(0, Width, Min, Max);
    glBegin(GL_TRIANGLE_STRIP);
    glVertex2d(5, m_Value);
    glVertex2d(0, m_Value + (Max - Min) / (m_Layout.m_ControlRect.Height() - m_Layout.m_XAxisHeight - m_Layout.m_TitleHeight - BorderSize * 2) * 5);
    glVertex2d(0, m_Value - (Max - Min) / (m_Layout.m_ControlRect.Height() - m_Layout.m_XAxisHeight - m_Layout.m_TitleHeight - BorderSize * 2) * 5);
    glEnd();
    glBegin(GL_LINE_STRIP);
    glVertex2d(5, m_Value);
    glVertex2d(Width - m_Layout.m_BorderSize, m_Value);
    glEnd();
    drawText(m_Caption, OGL_DRAWABLE_FONT_ARIAL_10, 7, m_Value + (Max - Min) / (m_Layout.m_ControlRect.Height() - m_Layout.m_XAxisHeight - m_Layout.m_TitleHeight - BorderSize * 2) * 5, GET_GLINT_R(m_Color), GET_GLINT_G(m_Color), GET_GLINT_B(m_Color));
}